/*
 * Copyright (c) 2003-2004, Inversoft, All Rights Reserved
 *
 * This software is distribuable under the GNU Lesser General Public License.
 * For more information visit gnu.org.
 */
package org.emergent.antbite.savant.ant.types;


import java.util.Date;

import org.apache.tools.ant.types.DataType;
import org.apache.tools.ant.types.Reference;

import org.emergent.antbite.savant.Artifact;


/**
 * <p>
 * This class is a single artifact produce by some project.
 * </p>
 *
 * @author  Brian Pontarelli
 */
public class ArtifactType extends DataType {

    private Artifact proxy = new Artifact();


    /**
     * Returns the Artifact object that this object is a proxy to.
     */ 
    public Artifact getProxy() {
        return proxy;
    }

    /**
     * Copy everything from the reference into this object rather than delegate.
     */
    public void setRefid(Reference reference) {
        super.setRefid(reference);

        ArtifactType art = (ArtifactType) reference.getReferencedObject(getProject());
        proxy.setGroup(art.getGroup());
        proxy.setName(art.getName());
        proxy.setProjectname(art.getProjectname());
        proxy.setType(art.getType());
        proxy.setVersion(art.getVersion());
    }

    public String getGroup() {
        return proxy.getGroup();
    }

    public void setGroup(String group) {
        if (isReference()) {
            throw tooManyAttributes();
        }

        proxy.setGroup(group);
    }

    public String getProjectname() {
        return proxy.getProjectname();
    }

    public void setProjectname(String project) {
        if (isReference()) {
            throw tooManyAttributes();
        }

        proxy.setProjectname(project);
    }

    public String getName() {
        return proxy.getName();
    }

    public void setName(String name) {
        if (isReference()) {
            throw tooManyAttributes();
        }

        proxy.setName(name);
    }

    public String getVersion() {
        return proxy.getVersion();
    }

    public void setVersion(String version) {
        if (isReference()) {
            throw tooManyAttributes();
        }

        proxy.setVersion(version);
    }

    public String getType() {
        return proxy.getType();
    }

    public void setType(String type) {
        if (isReference()) {
            throw tooManyAttributes();
        }

        proxy.setType(type);
    }

    public int getExpireminutes() {
        return proxy.getExpireminutes();
    }

    public void setExpireminutes(int expireMinutes) {
        proxy.setExpireminutes(expireMinutes);
    }

    public Date getExpiretime() {
        return proxy.getExpiretime();
    }

    public void setExpiretime(Date expireTime) {
        proxy.setExpiretime(expireTime);
    }
}